package ie.hurley.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import ie.hurley.model.ScoresList;
import ie.hurley.model.teachers;
import ie.hurley.service.ListScoresService;
import java.util.Map;
import java.util.List;
public class ListScores extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1085609084192281620L;
	private ListScoresService listScoreService;
	private int teacher_id;
	public ListScoresService getListScoreService() {
		return listScoreService;
	}
	public void setListScoreService(ListScoresService listScoreService) {
		this.listScoreService = listScoreService;
	}
	public int getTeacher_id() {
		return teacher_id;
	}
	public void setTeacher_id(int teacher_id) {
		this.teacher_id = teacher_id;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		Map<String,Object> sess = ActionContext.getContext().getSession();
		teachers user = (teachers)sess.get("login");
		teacher_id =user.getTeacher_id(); 
		List<ScoresList> list = this.listScoreService.listTeachersStudentsScores(teacher_id);
		@SuppressWarnings("unchecked")
		Map<String,List<ScoresList>> request = (Map<String,List<ScoresList>>)ActionContext.getContext().get("request");
		System.out.println(list.get(0).getTeacher());
		request.put("students", list);
		return "success";
	}
	
	 
	
}
